﻿using System;
using System.Linq;
using FluentValidation;

namespace LINQPad.OpenAccess.UI.ViewModel.Validators
{
    /// <summary>
    /// Base class for <see cref="IConnectionSettingsViewModel" /> validators.
    /// </summary>
    /// <typeparam name="TSettings">The type of the settings.</typeparam>
    public class ConnectionSettingsViewModelValidator<TSettings> : AbstractValidator<TSettings>
        where TSettings : IConnectionSettingsViewModel
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionSettingsViewModelValidator{TSettings}" /> class.
        /// </summary>
        public ConnectionSettingsViewModelValidator( )
        {
            this.RuleFor( e => e.Name )
                .NotEmpty( );
            this.RuleFor( e => e.ProviderName )
                .NotEmpty( )
                .WithMessage( "No provider set !" );
        }
    }
}
